<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="cn.cslg.news.entity.Member"%>
<%@ page import="java.util.ArrayList"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:include page="header.jsp" />
<script>
	$(document).ready(function() {
		$("#btnAdd").click(function() {
			document.location = '${ContextPath}admin/adduser.jsp';
		});
		$(".btnBanUser").click(function() {
			var uid = $(this).attr("user-id");
			$.post("${ContextPath}admin/banuser", {
				"uid" : uid
			}, function(data) {
				alert(data);
				document.location.reload();
			});
		});
	});

	function changepass(uid) {
		document.location = '${ContextPath}admin/change_userpass.jsp?uid='
				+ uid;
	}
</script>
<div class="section" style="min-height: 80vh">
	<div class="container">
		<div class="row">
			<div class="col-md-3">
				<jsp:include page="leftmenu.jsp" />
			</div>
			<div class="col-md-9">
				<div class="content-header">用户列表</div>
				<div style="margin-bottom: 10px">
					<input type="button" value="添加用户" id="btnAdd"
						onclick="document.location='${ContextPath}admin/adduser.jsp'" />
				</div>
				<div>
					<table class="table-responsive tlist">
						<tr>
							<td>uid</td>
							<td>用户名</td>
							<td>姓名</td>
							<td>电子邮件</td>
							<td>帐号激活</td>
							<td>帐号可用</td>
							<td>操作</td>
						</tr>
						<c:forEach items="${USERLIST}" var="vo">
							<tr>
								<td>${vo.uid}</td>
								<td>${vo.username}</td>
								<td>${vo.truename}</td>
								<td>${vo.email}</td>
								<td class="user-status${vo.activated}"></td>
								<td class="user-status${vo.enabled}"></td>
								<td><input type="button" value="修改密码"
									onclick="changepass('${vo.uid}')" /> <c:choose>
										<c:when test="${vo.enabled==1}">
											<input type="button" value="禁用" user-id="${vo.uid}"
												class="btnBanUser" />
										</c:when>
										<c:otherwise>
											<input type="button" value="启用" user-id="${vo.uid}"
												class="btnBanUser" />
										</c:otherwise>
									</c:choose></td>
							</tr>
						</c:forEach>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<jsp:include page="footer.jsp" />